<?php
// No directAcces
defined('_AppBackMiage') or die('Restricted access');
if(isAdministrateur ()){
    include_once (DS . "backoffice/include/header.php");
    include_once( DS . "backoffice/include/toppanel_utilisateurs.php");

    if(isset($_POST['submit']))
    {
        $ufr = new UFR();

        $form = true;
        if(isset($_POST['name']) && !empty($_POST['name']))
        {
            $tmp = $ufr->setNom($_POST['name']);
            var_dump($tmp);
            if($tmp['boolOk'] === false)
            {
                $errMSG = $tmp['errmsg'];
                $form = false;
            }
        }

        if($form)
        {
            $ufr->insert();
            redirectTo(URLBACK."_userufr_list");
        }

    }

    ?>
    <div id="wrapper">
        <div id="content">
            <div id="box">
                <h3 id="adduser">Ajout d'un UFR</h3>
                <form id="form" method="post">
                <fieldset id="personal">
                    <legend>Informations</legend>
                    <label for="name">Nom : </label>
                    <input name="name" id="name" type="text" tabindex="1" />
                    <?php if($form===false){ echo $errMSG; } ?>
                    <br />
                </fieldset>
                <div align="center">
                    <input id="button1" type="submit" name="submit" value="Ajouter" />
                    <input id="button2" type="reset" />
                </div>
                </form>
            </div>
        </div>
    <?php
        include_once (DS . "backoffice/include/sidebar.php");
        include_once (DS . "backoffice/include/footer.php");
}
else
{
    redirectTo(URLBACK);
}
?>